"""
SPU管理序列化器
"""
from django.db.models import fields
from rest_framework import serializers
from goods.models import SPU, Brand, GoodsCategory

class SPUSpecificationSerializer(serializers.ModelSerializer):
    """
    SPU可选分类一级二级三级
    """
    class Meta:
        model = GoodsCategory
        fields = ['id', 'name']


class BrandModelListSerializer(serializers.ModelSerializer):
    """
    SPU可选品牌
    """
    class Meta:
        model = Brand
        fields = ['id', 'name']


class SPUModelSerializer(serializers.ModelSerializer):
    """
    SPU管理序列化器
    """
    brand = serializers.StringRelatedField()
    brand_id = serializers.IntegerField()
    category1_id = serializers.IntegerField()
    category2_id = serializers.IntegerField()
    category3_id = serializers.IntegerField()
    class Meta:
        model = SPU
        exclude = ['category1', 'category2', 'category3']